﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;

namespace OneStop.Calculations
{
    static class Extensions
    {
        public static void Sort(this ObservableCollection<Gas> gases)
        {
            ObservableCollection<Gas> sorted = new ObservableCollection<Gas>();

            foreach (Gas g in gases.OrderBy(g => g, new GasModComparer()).ToList<Gas>())
            {
                sorted.Add(g);
            }

            gases = sorted;            
        }

        public static Gas FindByShortName(this ObservableCollection<Gas> gases, Gas match)
        {
            foreach (Gas g in gases)
            {
                if (g.ShortName == match.ShortName)
                {
                    return g;
                }
            }

            return null;
        }
    }
}
